package org.openit.portail.dao.impl;

import java.util.List;

import org.hibernate.SessionFactory;
import org.openit.portail.dao.ParametreServiceDao;
import org.openit.portail.model.ParametreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;


@Repository
@Transactional
public class ParametreServiceDaoImpl implements ParametreServiceDao {

	private SessionFactory sessionFactory;

	public ParametreService get(Long id) {
		return (ParametreService) sessionFactory.getCurrentSession()
			.createQuery("from ParametreService parametreservice where parametreservice.id = :id")
			.setLong("id", id).uniqueResult();
	}

	public void delete(ParametreService parametreservice) {
		sessionFactory.getCurrentSession().delete(parametreservice);
	}

	@SuppressWarnings("unchecked")
	public List<ParametreService> findAll() {
		return sessionFactory.getCurrentSession().createQuery("from ParametreService").list();
	}

	public void save(ParametreService parametreservice) {
		sessionFactory.getCurrentSession().merge(parametreservice);
		
	}
	
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	
}
